package org.kjtc;

import org.junit.runner.RunWith;
import org.kjtc.entity.WxChargingstationEntity;
import org.kjtc.service.MapFindingPileService;
import org.kjtc.weChatUtil.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * @Author: xiaojinlu1990@ 163.com
 * @Date: 2019/3/22 0022.
 * @Version 1.0
 * 根据给定范围查询出所有的附近站点
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class searchAllStation {
    @Autowired
    private MapFindingPileService mapFindingPileService;

    @org.junit.Test
    public void Test(){
        String longitude = "116.264765";
        String latitude = "40.237346";

        List<WxChargingstationEntity> list = mapFindingPileService.chargingstationList();
        for (int i = 0; i < list.size(); i++) {
            WxChargingstationEntity wxEntity =  list.get(i);
            double calcultion = StringUtils.getDistance(latitude,longitude,""+wxEntity.getLatitude(),""+wxEntity.getLongitude());
            if(20000.000000>calcultion){
                System.out.println(calcultion+":"+wxEntity.getChargingstationname());
            }
           // System.out.println("'"+wxEntity.getLongitude()+"','"+wxEntity.getLatitude()+"'");
         }

    }


}
